package com.wisezone.home01;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
import java.util.Scanner;

public class Test4 {
    public static void main(String[] args) {
        String userName=null;
        String passWord=null;
        Scanner scanner=new Scanner(System.in);

        System.out.println("请输入用户名：");
        userName=scanner.next();
        System.out.println("请输入密码：");
        passWord=scanner.next();


        //读取配置文件:database
        Properties properties=new Properties();
        try{
            InputStream inputStream=new FileInputStream("db.properties");
            properties.load(inputStream);
            String user=properties.getProperty("user");
            String pass=properties.getProperty("pass");

            //比较
            if(user.equals(userName)&&pass.equals(passWord))
            {
                System.out.println("登录成功。");
            }
        }catch (Exception e){
            e.printStackTrace();
        }


    }
}
